import { View } from "../../../mvc/core/View";
import { LayerManager } from "../../manager/LayerManager";
import { ObjCreate } from "../common/ObjCreate";
import { ResFileConst } from "../../resource/ResFileConst";
import { RolePlayer } from "../../scene/player/entity/RolePlayer";
import { PlayerEvent } from "../../scene/events/PlayerEvent";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { EventName } from "../../mvc/EventName";
import { DataEvent } from "../../events/DataEvent";
import { GameController } from "../../mvc/GameController";
import { GameUI } from "../mainUI/GameUI";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
//class CrossBeachBtnView
    
    export  class CrossBeachBtnView extends View
    {
        constructor()
        {
            super();
            this.layer = LayerManager.uiLayer;
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this._crossBeachBtn = ObjCreate.createGLoadedButton(ResFileConst.SunBath, 0, 0, 60, 60, this);
            this._crossBeachBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onClickBtn);
            RolePlayer.instance.addEventListener(PlayerEvent.SunBathChange, this.onSunBathChange);
            Dispatcher.addEventListener(EventName.GameUINavBarResize, this.onGameUIResize);
            this.resetPosition();
            return;
        }

        /* internal  */onClickBtn(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.SunBath, !RolePlayer.instance.isSunBath));
            return;
        }

        /* internal  */onSunBathChange(arg1: PlayerEvent): void
        {
            this.updateBtn();
            return;
        }

        /* internal  */onGameUIResize(arg1: DataEvent): void
        {
            this.resetPosition();
            return;
        }

        /* internal  */resetPosition(): void
        {
            this._crossBeachBtn.x = (GameController.gameui.view as GameUI).navBarX + 465;
            this._crossBeachBtn.y = (GameController.gameui.view as GameUI).navBarY - 130;
            return;
        }

        /* internal  */updateBtn(): void
        {
            return;
        }

        /* internal */ /* var */_crossBeachBtn: GLoadedButton;
    }
